@@ -151,4 +151,26 @@ module SortableEvents |
||
| 151 | 151 |
orders |
| 152 | 152 |
).collect!(&:last) |
| 153 | 153 |
end |
| 154 |
+ |
|
| 155 |
+ # The emulation of Module#prepend provided by lib/prepend.rb does |
|
| 156 |
+ # not work for methods defined after a call of prepend. |
|
| 157 |
+ if Module.method(:prepend).source_location |
|
| 158 |
+ module ClassMethods |
|
| 159 |
+ def can_order_created_events! |
|
| 160 |
+ raise if cannot_create_events? |
|
| 161 |
+ @can_order_created_events = true |
|
| 162 |
+ end |
|
| 163 |
+ |
|
| 164 |
+ def can_order_created_events? |
|
| 165 |
+ !!@can_order_created_events |
|
| 166 |
+ end |
|
| 167 |
+ end |
|
| 168 |
+ |
|
| 169 |
+ def initialize(*args) |
|
| 170 |
+ if self.class.instance_variable_get(:@can_order_created_events) |
|
| 171 |
+ self.class.__send__ :prepend, SortableEvents::AutomaticSorter |
|
| 172 |
+ end |
|
| 173 |
+ super |
|
| 174 |
+ end |
|
| 175 |
+ end |
|
| 154 | 176 |
end |